#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = (1 << 20) + 5;
using cd = complex<double>;
const double PI = acos(-1);

// void fft(vector<cd>& a, bool invert) {
//   int n = a.size();
//   if (n == 1) return;
//   vector<cd> a0(n / 2), a1(n / 2);
//   rep(i, 0, n / 2 - 1) {
//     a0[i] = a[i * 2];
//     a1[i] = a[i * 2 + 1];
//   }
//   fft(a0, invert), fft(a1, invert);
//   double ang = 2 * PI / n * (invert ? -1 : 1);
//   cd w(1), w1(cos(ang), sin(ang));
//   rep(i, 0, n / 2 - 1) {
//     a[i] = a0[i] + a1[i] * w;
//     a[i + n / 2] = a0[i] - a1[i] * w;
//     if (invert) a[i] /= 2, a[i + n / 2] /= 2;
//     w *= w1;
//   }
// }
void change(vector<int>& a) {
  int n = a.size();
  a[0] = 0;
  rep(i, 1, n - 1) { a[i] = (a[i >> 1] >> 1) + (i & 1 ? n / 2 : 0); }
}
void fft(vector<cd>& a, bool invert) {
  int n = a.size();
  vector<int> rev(n);
  change(rev);
  rep(i, 0, n - 1) if (i < rev[i]) swap(a[i], a[rev[i]]);

  for (int len = 2; len <= n; len <<= 1) {
    double ang = 2 * PI / len * (invert ? -1 : 1);
    cd w1(cos(ang), sin(ang));
    for (int i = 0; i < n; i += len) {
      cd w(1);
      for (int j = 0; j < len / 2; j++) {
        cd u = a[i + j], v = a[i + j + len / 2] * w;
        a[i + j] = u + v;
        a[i + j + len / 2] = u - v;
        w *= w1;
      }
    }
  }
  if (invert)
    for (cd& x : a) x /= n;
}
vector<int> multiply(const vector<int>& a, const vector<int>& b) {
  vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
  int n = 1;
  while (n < a.size() + b.size()) n <<= 1;
  fa.resize(n), fb.resize(n);
  fft(fa, 0), fft(fb, 0);
  rep(i, 0, n - 1) fa[i] *= fb[i];
  fft(fa, 1);
  vector<int> res(n);
  rep(i, 0, n - 1) res[i] = round(fa[i].real());
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1, 0), b(m + 1, 0);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, m) cin >> b[i];
  vector<int> c = multiply(a, b);
  rep(i, 0, n + m) cout << c[i] << ' ';
  return 0;
}